/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.tesis2.pucp.Util;

import com.itextpdf.text.BaseColor;
import com.itextpdf.text.Document;
import com.itextpdf.text.Element;
import com.itextpdf.text.Font;
import com.itextpdf.text.Font.FontStyle;
import com.itextpdf.text.Image;
import com.itextpdf.text.PageSize;
import com.itextpdf.text.Paragraph;
import com.itextpdf.text.Rectangle;
import com.itextpdf.text.pdf.PdfPCell;
import com.itextpdf.text.pdf.PdfPTable;
import com.itextpdf.text.pdf.PdfWriter;
import java.io.File;
import java.io.FileOutputStream;
import java.io.OutputStream;
import java.util.List;


/**
 *
 * @author Yanire
 */
public class Pdf {
    
    public static String toPdf(String nombArch, String arch) {

        String rutaArchivo = "";
        try {
            OutputStream file;

            file = new FileOutputStream(new File(nombArch + ".pdf"));
            rutaArchivo = nombArch + ".pdf";



            Document document = new Document(new Rectangle(680, 342), 10, 10, 10, 10);
            PdfWriter.getInstance(document, file);
            document.open();

            document.open();



            //Tabla de la factura y fecha
            PdfPCell cell;
            PdfPTable table = new PdfPTable(1);

            //com.lowagie.text.Font FUENTE_NUM = new com.lowagie.text.Font(com.lowagie.text.Font.COURIER, 22, com.lowagie.text.Font.BOLD, new Color(255, 0, 0));

            //Font FUENTE_NUM = new Font( "COURIER",Font.BOLD,22);


            cell = new PdfPCell(new Paragraph(""));
            cell.setFixedHeight(23f);
            cell.setBorder(PdfPCell.NO_BORDER);
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            table.addCell(cell);

            cell = new PdfPCell(new Paragraph("          " + arch, new Font(Font.FontFamily.HELVETICA, 30)));
            cell.setFixedHeight(55f);
            cell.setBorder(PdfPCell.NO_BORDER);
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            table.addCell(cell);

            document.add(table);//Agraga la tabla al documento

            document.add(new Paragraph(" "));

            document.close();
            
            file.close();

        } catch (Exception e) {

            e.printStackTrace();
        }
        return rutaArchivo;
    }
}
